-- @Author: 作者QQ381990860
-- @Date:   2021-11-29 01:22:28
-- @Last Modified by:   作者QQ381990860
-- @Last Modified time: 2022-09-18 08:23:57

local 生肖系统 = class()
local tp
local zts1,zts
local wz = require("gge文字类")
function 生肖系统:初始化(根)
   	local 资源 = 根.资源
	local 按钮 = 根._按钮
	local 自适应 = 根._自适应
	 tp = 根
  	self.ID = 2017
    self.x = 90+(全局游戏宽度-800)/2
    self.y = 0
	self.xx = 0
	self.yy = 0
	self.注释 = "生肖系统"
	self.可视 = false
	self.鼠标 = false
	self.焦点 = false
	self.可移动 = true
	self.窗口时间 = 0
	self.页数=0
	self.模式=0
	self.选中=0
	zts = wz.创建(程序目录.."Data/pic/hkyt_w5.ttf",20,false,false,true)
	zts1 = wz.创建(程序目录.."Data/pic/hkyt_w5.ttf",15,false,false,true)
	self.资源组 = {
   [1] = tp._自适应(0,1,450,350,3,9),
    [70] = tp._自适应(5,1,430,330,3,9),
   [5] = 按钮.创建(资源:载入('新关闭按钮',"动画"),0,0,4,true,true),	
   [2]=按钮.创建(自适应.创建(11,4,75,20,1,3),0,0,4,true,true,"突     破"),
   [3]=按钮.创建(自适应.创建(11,4,75,20,1,3),0,0,4,true,true,"洗     练"),
   [4]=按钮.创建(自适应.创建(11,4,75,20,1,3),0,0,4,true,true,"升     级"),
   [6] =按钮.创建(资源:载入('生肖龙',"动画"),0,0,1,true,true),

     }
     self.生肖 = {
    [1] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80010000),0,0,1,true,true),
    [2] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80000000),0,0,1,true,true),
    [3] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80012000),0,0,1,true,true),
    [4] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80023000),0,0,1,true,true),
    [5] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80034000),0,0,1,true,true),
	[6] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80043000),0,0,1,true,true),
	[7] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80044000),0,0,1,true,true),
	[8] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80045000),0,0,1,true,true),
	[9] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80046000),0,0,1,true,true),
	[10] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80047000),0,0,1,true,true),
	[11] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80020000),0,0,1,true,true),
	[12] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80030000),0,0,1,true,true),
	[13] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80040000),0,0,1,true,true),--
	[14] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80050000),0,0,1,true,true),
	[15] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80060000),0,0,1,true,true),
	[16] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80070000),0,0,1,true,true),
	[17] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80080000),0,0,1,true,true),
	[18] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80090000),0,0,1,true,true),
	[19] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80051000),0,0,1,true,true),
	[20] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80011000),0,0,1,true,true),
	[21] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80013000),0,0,1,true,true),
	[22] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80014000),0,0,1,true,true),
	[23] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80015000),0,0,1,true,true),
	[24] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80016000),0,0,1,true,true),
	[25] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80053000),0,0,1,true,true),--
	[26] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80031000),0,0,1,true,true),
	[27] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80032000),0,0,1,true,true),
	[28] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80033000),0,0,1,true,true),
	[29] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80035000),0,0,1,true,true),
	[30] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80036000),0,0,1,true,true),
	[31] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80037000),0,0,1,true,true),
	[32] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80038000),0,0,1,true,true),
	[33] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80039000),0,0,1,true,true),
	[34] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80052000),0,0,1,true,true),
	[35] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80041000),0,0,1,true,true),
	[36] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80042000),0,0,1,true,true),
	[37] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80017000),0,0,1,true,true),---
	[38] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80018000),0,0,1,true,true),
	[39] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80019000),0,0,1,true,true),
	[40] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80054000),0,0,1,true,true),
	[41] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80021000),0,0,1,true,true),
	[42] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80022000),0,0,1,true,true),
	[43] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80024000),0,0,1,true,true),
	[44] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80025000),0,0,1,true,true),
	[45] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80026000),0,0,1,true,true),
	[46] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80027000),0,0,1,true,true),
	[47] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80028000),0,0,1,true,true),
	[48] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80029000),0,0,1,true,true),
	[49] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80017000),0,0,1,true,true),   --
	[50] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80018000),0,0,1,true,true),
	[51] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80019000),0,0,1,true,true),
	[52] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80054000),0,0,1,true,true),
	[53] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80021000),0,0,1,true,true),
	[54] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80022000),0,0,1,true,true),
	[55] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80024000),0,0,1,true,true),
	[56] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80025000),0,0,1,true,true),
	[57] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80026000),0,0,1,true,true),
	[58] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80027000),0,0,1,true,true),
	[59] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80028000),0,0,1,true,true),
	[60] = 按钮.创建(资源:载入('sx.wdf',"网易WDF动画",0X80029000),0,0,1,true,true)
     }
end
function 生肖系统:打开(数据)
	if self.可视 then
		self.可视=false
	else
	table.insert(tp.窗口_,self)
		tp.运行时间 = tp.运行时间 + 1
		self.窗口时间 = tp.运行时间
	    self.可视=true
		self.数据 = 数据
	end
end

function 生肖系统:刷新(数据)
self.数据 = 数据
end

function 生肖系统:显示(dt,x,y)
	self.焦点=false	
	self.资源组[1]:显示(self.x,self.y)
	tp.窗口标题背景_:显示(self.x+self.资源组[1].宽度/2-90,self.y)
	zts1:置颜色(0xFFFFFFFF):显示(self.x+170,self.y+2,"生 肖 系 统")

	self.资源组[70]:显示(self.x+10,self.y+20)
	self.资源组[2]:更新(x,y)
	self.资源组[3]:更新(x,y)
	self.资源组[4]:更新(x,y)
	self.资源组[6]:更新(x,y)

	self.资源组[2]:显示(self.x+350,self.y+90)
	self.资源组[3]:显示(self.x+350,self.y+60)
	self.资源组[4]:显示(self.x+350,self.y+30)
	self.资源组[6]:显示(self.x+300,self.y+144)

	
		if self.资源组[2]:事件判断()  then
	if self.选中 == 0 then
	tp.提示:写入("#Y/少侠先选择要操作的位置")
	return
	end
	客户端:发送数据(self.选中, 1000, 5)
	elseif self.资源组[3]:事件判断() then
		if self.选中 == 0 then
	tp.提示:写入("#Y/少侠先选择要操作的位置")
	return
	end
	客户端:发送数据(self.选中, 1001, 5)
		elseif self.资源组[4]:事件判断() then
		if self.选中 == 0 then
	tp.提示:写入("#Y/少侠先选择要操作的位置")
	return
	end
	客户端:发送数据(self.选中, 1003, 5)
	end
	for n = 1,12 do
	local 选中 = 0
	local i = 0 
	if self.数据[n].等级 == 1 or self.数据[n].等级 == 0 then
	i = n
	elseif self.数据[n].等级 == 2 then
	i = n+12
	elseif self.数据[n].等级 == 3 then
	i = n+24
	elseif self.数据[n].等级 == 4 then
	i = n+36
	else
	i = n+48
	end
	if n < 5 then


	self.生肖[i]:更新(x,y)
	self.生肖[i]:显示(self.x+45,self.y+50+(n-1)*50)
	end
	if n > 4 and n < 9 then

	self.生肖[i]:更新(x,y)
	self.生肖[i]:显示(self.x+100,self.y+50+(n-5)*50)
	end
	if n > 8 and n < 13 then
	self.生肖[i]:更新(x,y)
	self.生肖[i]:显示(self.x+150+(9-5),self.y+50+(n-9)*50)
	end
	if self.生肖[i]:事件判断() and 选中 == 0 then
		self.选中 = n
		选中 = 1
	end
	if self.生肖[i]:是否选中(x,y) then
		tp.提示:生肖提示(x,y,self.数据[n])
	end
	if n == 12 then
	选中 = 0
	end
	end
		if self.资源组[6]:是否选中(x,y) then
		tp.提示:生肖提示2(x,y,self.数据)
	end
end

function 生肖系统:初始移动(x,y)
	tp.运行时间 = tp.运行时间 + 1
	if not tp.消息栏焦点 then
  		self.窗口时间 = tp.运行时间
 	end
	if not self.焦点 then
		tp.移动窗口 = true
	end
	if self.鼠标 and  not self.焦点 then
		self.xx = x - self.x
		self.yy = y - self.y
	end
end

function 生肖系统:开始移动(x,y)
	if self.鼠标 then
		self.x = x - self.xx
		self.y = y - self.yy


	end
end
function 生肖系统:检查点(x,y)
	if self.可视 and self.资源组[1]:是否选中(x,y)  then
		return true
	else
		return false
	end
end

return 生肖系统